package com.yunji.ylexpiration.Controller;

import com.yunji.ylexpiration.entity.FurnUser;
import com.yunji.ylexpiration.service.RegisterService;
import com.yunji.ylexpiration.util.SimpleResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 注册
 */
@Controller
public class LogonController {
@Autowired
private RegisterService registerService;

  @GetMapping("/reg.html")
    public  String reg(){

      return "reg";
  }
 @PostMapping("/reg2")
 @ResponseBody
    public  SimpleResponse insertSelective(String email,String paw1){
      try {
          FurnUser furnUser=new FurnUser();
          furnUser.setUserAccount(email);
          furnUser.setUserPassword(paw1);
          int d=registerService.insertSelective(furnUser);
          if (d>0){
              return SimpleResponse.ok(d);
          }else {
              return SimpleResponse.ok(null);
          }
      }catch (Exception e){
          e.printStackTrace();
          return SimpleResponse.error(5555,"新增错误","详情看上面");
      }
 }

}
